package com.treasure.hunt.mode

import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.blankj.utilcode.util.LogUtils
import com.module.lemlin.base.BaseViewModel
import com.module.lemlin.mode.ViewModelSubscribe
import com.module.lemlin.rxhttp.HttpServiceData
import com.module.lemlin.rxhttp.HttpServiceResponse
import com.treasure.hunt.api.*
import com.treasure.hunt.entity.*
import io.reactivex.rxjava3.disposables.Disposable

open class LuckyViewMode(application: Application) : AdViewMode(application) {


    val luckyNumLiveData = MutableLiveData<HttpServiceResponse<LuckyNumResponse>>()
    val luckyGiftLiveData = MutableLiveData<HttpServiceResponse<LuckyGiftResponse>>()
    val luckyFlopLiveData = MutableLiveData<HttpServiceResponse<LuckyFlopResponse>>()
    val luckyGridListLiveData = MutableLiveData<HttpServiceResponse<LuckyGridListResponse>>()
    val luckyGridLiveData = MutableLiveData<HttpServiceResponse<LuckyGridResponse>>()

    fun luckyGetLuckDraw(type: Int) {
        val disposable: Disposable =
            luckyGetLuckDraw(type, ViewModelSubscribe(luckyNumLiveData))
        dispose.add(disposable)
    }

    private fun luckyOrdinaryChest() {
        val disposable: Disposable =
            luckyOrdinaryChest(ViewModelSubscribe(luckyGiftLiveData))
        dispose.add(disposable)
    }

    private fun luckyLuxuryChest() {
        val disposable: Disposable =
            luckyLuxuryChest(ViewModelSubscribe(luckyGiftLiveData))
        dispose.add(disposable)
    }

    fun luckyChest(type: Int) {
        if (type == 1) {
            luckyOrdinaryChest()
        }
        if (type == 2) {
            luckyLuxuryChest()
        }
    }

    fun luckyFlop(position: Int) {
        val disposable: Disposable =
            luckyFlop(position, ViewModelSubscribe(luckyFlopLiveData))
        dispose.add(disposable)
    }

    fun luckyTurntable(page: Int = 18) {
        val disposable: Disposable =
            luckyTurntable(page, ViewModelSubscribe(luckyGridListLiveData))
        dispose.add(disposable)
    }

    fun luckyTurntableWinningThePrize() {
        val disposable: Disposable =
            luckyTurntableWinningThePrize(ViewModelSubscribe(luckyGridLiveData))
        dispose.add(disposable)
    }

}